home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 2 / Tech Arsenal 2 (Arsenal Computer).iso / clipper / s93bsp.exe / S87 / HOUSE00.PRG < prev    next >
Encoding:
Text File  |  1993-10-26  |  5.3 KB  |  232 lines

  1. procedure HOUSEMAIN
  2. *       H O U S E 0 0
  3. *       Main controlling routine for Housekeeping
  4. private HSCOM, OLDMLIN, RTITLE, RCHOIX
  5. QBCHOICE = 1
  6. do while .t.
  7. *    Last change:  MIB  26 Oct 93    5:51 pm
  8.  
  9.     close database
  10.     do QBLAYOUT with "Housekeeping"
  11.     do QBBOX with 40
  12.     do QBMENU with "HOUSEKE",40
  13.     RTITLE = QBPROC
  14.     RCHOIX = QBCHOICE
  15.     do case
  16.     case RCHOIX=0 .or. RCHOIX=5
  17.         exit
  18.     case RCHOIX=1
  19.         do QBLAYOUT with RTITLE
  20.         do CTEDIT with 5, 19, 15, 1
  21.     case RCHOIX=2
  22.         do QBLAYOUT with RTITLE
  23.         do QBBOX with 40
  24.     case RCHOIX=3
  25.         do QBLAYOUT with RTITLE
  26.         do QBBOX with 40
  27.         do BODARCH
  28.     case RCHOIX=4
  29.         do QBLAYOUT with RTITLE
  30.         do QBBOX with 40
  31.         do BODREST
  32.     endcase
  33.     QBCHOICE = RCHOIX
  34. enddo
  35. set softseek off
  36. return
  37.  
  38. *******************************************************************
  39.  
  40. procedure BODARCH
  41. *   B O D A R C H . P R G
  42. *  Program to archive Invoices
  43. private STATUS, D1, D2
  44. status = 0
  45. store ctod("") to D1,D2
  46.  
  47. select 0
  48. use PARTS index PARTINV alias PARTS
  49. select 0
  50. use INVOICE index INVDATE,INVNUM, INVCUST alias INVOICE
  51.  
  52. * Method: Create structure on Disc a:
  53. adate = date()
  54.  
  55. @ 5, 26 SAY " First date: "
  56. @ 7, 26 say "Second date: "
  57. do QB2DATES with "Input Start and Finish dates",5,39,D1,7,39,D2
  58.  
  59. set softseek on
  60. seek dtos(D1)
  61. IF eof()
  62.     DO qbmess WITH "No Invoices to be archived",colflash,5
  63.     RETURN
  64. ENDIF
  65.  
  66. IF QBYESNO("OK to Continue?")="N" .or. GETOUT
  67.     CLOSE DATABASE
  68.     RETURN
  69. ENDIF
  70.  
  71. DO qbmess WITH "Place a formatted floppy in drive A",colhead,0
  72. if .not. DRIVEOK()
  73.     GETOUT = .f.
  74.     return
  75. endif
  76. DO qbmess WITH "Selecting Invoices",colflash,0
  77.  
  78.  
  79. DO qbmess WITH "Archiving Invoices and Parts to Floppy",colflash,0
  80.  
  81. * Create Files on Floppy
  82. SELECT invoice
  83. copy structure to A:invoice
  84. SELECT PARTS
  85. copy structure to A:PARTS
  86. select 0
  87. use A:PARTS alias APARTS
  88. select 0
  89. use a:INVOICE  alias ANVOICE
  90.  
  91. go top
  92. select INVOICE
  93. set softseek on                    && Invoices
  94. seek dtos(D1)
  95. DO WHILE INVOICE->DATEINV<=D2 .and. ! eof()
  96.     getrec()                                && Get the current record in the database
  97.     select ANVOICE
  98.     putrec()                                && Put it in the other
  99.     MINVNO = ANVOICE->INVNO                 && Get a number from A drive
  100.  
  101.     set softseek off                        && Part by Invoice #
  102.     select PARTS
  103.     seek str(MINVNO,5)                      && Find in main file
  104.     do while  .not. eof() .and. MINVNO=PARTS->INVNO
  105.         getrec()
  106.         select APARTS
  107.         putrec()
  108.         select PARTS
  109.         do QBWIPE                           && Erase
  110.         seek str(MINVNO,5)                  && Find in main file
  111.     enddo
  112.  
  113.     set softseek on                         && Erase Invoice, Get next
  114.     select INVOICE
  115.     do QBWIPE
  116.     seek dtos(D1)
  117. ENDDO
  118.  
  119. DO qbclmess
  120. CLOSE DATABASE
  121. DO qbmess WITH "Remove floppy from drive A: and label it",colhead,0
  122. WAIT
  123. set softseek off
  124.  
  125. do QBCLMESS
  126. RETURN
  127.  
  128. *******************************************************************
  129. function GETREC
  130. private NumFlds, T, I
  131. NumFlds = fcount()
  132. public DBREC[NumFlds], DBNAME[NumFlds]
  133.  
  134. afields(DBNAME)
  135. for I=1 to NumFlds
  136.     T = DBNAME[I]
  137.     DBREC[I] = &T
  138. next
  139.  
  140. blimempak(-1)
  141.  
  142. return .t.
  143.  
  144. *******************************************************************
  145. function PUTREC
  146. private NumFlds, T, I
  147. NumFlds = fcount()
  148.  
  149. append blank
  150. afields(DBNAME)
  151. for I=1 to NumFlds
  152.     T = DBNAME[I]
  153.     replace &T with DBREC[I]
  154. next
  155.  
  156. blimempak(-1)
  157.     
  158. return .t.
  159.  
  160. *******************************************************************
  161.  
  162. procedure BODREST
  163. *   B O D R E S T
  164. private STATUS
  165. status = 0
  166. select 0
  167. use INVOICE index INVNUM, INVDATE, INVCUST
  168. select 0
  169. use PARTS index PARTINV
  170.  
  171. @ 5, 26 SAY "Restoring Invoices"
  172.  
  173. IF QBYESNO("OK to Continue?")="N"
  174.     CLOSE DATABASE
  175.     RETURN
  176. ENDIF
  177.  
  178. DO WHILE .t.
  179.     DO qbmess WITH "Place the Archive floppy in drive A",colhead,0
  180.     if .not. DRIVEOK()
  181.         GETOUT = .f.
  182.         return
  183.     endif
  184.     IF  file("a:invoice.dbf") .and. file("a:parts.dbf")
  185.         do QBMESS with "Appending Invoices from Floppy",colhead,0
  186.         select INVOICE
  187.         append from a:INVOICE
  188.         select PARTS
  189.         append from a:PARTS
  190.         exit
  191.     ELSE
  192.         DO qbmess WITH "Floppy does not contain correct files - try again",;
  193.         colflash,5
  194.         IF QBYESNO("OK to try again?")="N"
  195.             CLOSE DATABASE
  196.             RETURN
  197.         ENDIF
  198.     ENDIF
  199. ENDDO
  200. do QBMESS with "Reindexing Invoices",colhead,0
  201. select INVOICE
  202. index on str(INVNO,5) to INVNUM
  203. index on dtos(DATEOUT) + CUSTTYPE to INVDATE
  204. index on CUSTTYPE + dtos(DATEOUT) to INVCUST
  205. index on upper(OWNNAME) to INVNAME
  206.  
  207. select parts
  208. index on str(INVNO,5)+str(PLINENO,2) to PARTINV
  209.  
  210. DO qbmess WITH "Remove floppy from drive A: ",colhead,0
  211. WAIT
  212.  
  213. CLOSE DATABASE
  214.  
  215. RETURN
  216.  
  217. *******************************************************************
  218.  
  219.  
  220. *******************************************************************
  221. function DRIVEOK
  222. GETOUT = .f.
  223. do while .not. isdrive("A")
  224.     ACTION = QBPROMPT("Continue|Quit|","Floppy is not ready - correct and continue or Quit",1)
  225.     if ACTION<>1
  226.         GETOUT = .t.
  227.         exit
  228.     endif
  229. enddo
  230.  
  231. return .not. GETOUT
  232.